package com.lagou.controller;

import com.lagou.pojo.Article;
import com.lagou.pojo.User;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import sun.swing.BakedArrayList;

import java.util.ArrayList;
import java.util.List;

@Controller
public class CommentController {



    @Autowired
    private ArticleService articleService;
    @RequestMapping("/index")
    public String index(Model model) throws  Exception{
        List<Article> articleList=articleService.getAllArticle();
        model.addAttribute("articleList",articleList);
  /*    model.addAttribute("name","张三");*/


        return "index";
    }

    @RequestMapping("/test")
    public String test(Model model){
        List<User> users=new ArrayList<User>();
        User user=new User("徐奥","18");
        User user1=new User("小红","19");
        User user2=new User("小白","20");
        users.add(user);
        users.add(user1);
        users.add(user2);
        model.addAttribute("users",users);
        return "login";
    }
}
